package com.appkubes.mall.restful.application.common.base;


import com.appkubes.common.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@Slf4j
public class BaseController {

    @Autowired
    protected HttpServletRequest servletRequest;

    @Value("${ConfigValue.imgUrl}")
    protected String imgUrl;

    @Value("${wx.notifyUrl}")
    protected String notifyUrl;

    @Value("${ConfigValue.superPlatformUuid}")
    protected String superPlatformUuid;


    protected Response errorResponse(String msg) {
        Response resultData = new Response();
        resultData.setCode(1);
        resultData.setMsg(msg);
        return resultData;
    }


    protected Response imgResponse(Object data) {
        Response resultData = new Response();
        resultData.setCodeSuccess();
        resultData.setData(data);
        Map<String, String> other = new HashMap<>();
        other.put("other", imgUrl);
        other.put("img_root", imgUrl);
        resultData.setOther(other);
        return resultData;
    }


    protected String getAppKey() {
        return "123";
    }

    protected String getSuperPlatformUuid() {
        return superPlatformUuid;
    }
}
